package com.cscec.omega.controller;

import com.cscec.omega.utils.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/api/file")
public class FileController {

    private static Logger logger = LoggerFactory.getLogger(FileController.class);

    @RequestMapping("/download")
    public ResponseEntity downLoad(HttpServletResponse response, String path){
        boolean result = FileUtil.downLoad(response, path);
        if (result){
            return ResponseEntity.status(-100).body("下载失败");
        }
        return ResponseEntity.ok("下载成功");
    }
}